<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>函数定义</title>
		<script>
			//定义函数
			function print99() {
				for (var i = 1; i <= 9; i++) {
					for (var j = 1; j <= i; j++) {
						document.write(j + "*" + i + "=" + (i * j) + "&nbsp;&nbsp;&nbsp;&nbsp;");
					}
					document.write("<br/>");
				}
			}
			//调用函数
			print99();

			function fac1(num) {
				var r = 1;
				for (var i = num; i >= 1; i--) {
					r *= i;
				}
				//如果有return则表示该函数有返回值,没有return就表示没有返回值
				return r;
			}

			function fac2(num) {
				if (num == 1) {
					return 1;
				}
				return num * fac2(num - 1);
			}

			//调用函数
			document.write(fac2(10));
		</script>
	</head>
	<body>
	</body>
</html>
